/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scheduler;

import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 * @author Musikero
 */
public class StudentWindow extends javax.swing.JFrame {
    
    static int realDay, realMonth, realYear, currentMonth, currentYear;
    private static String date = new SimpleDateFormat("dd-MM-yyyy").format(new Date());

    

    /**
     * Creates new form StudentWindow
     */
    public StudentWindow() {
        
        GregorianCalendar cal = new GregorianCalendar();
        realDay = cal.get(GregorianCalendar.DAY_OF_MONTH);
        realMonth = cal.get(GregorianCalendar.MONTH);
        realYear = cal.get(GregorianCalendar.YEAR);
        currentMonth = realMonth;
        currentYear = realYear;
        
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        WelcomeLabel = new javax.swing.JLabel();
        StudentNameField = new javax.swing.JTextField();
        CourseYearLabel = new javax.swing.JLabel();
        StudentCourseYearField = new javax.swing.JTextField();
        DroppedClassCardsLabel = new javax.swing.JLabel();
        SubjectLabel = new javax.swing.JLabel();
        StudentSubjectField = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        StudentTable = new javax.swing.JTable();
        StudentChangePassword = new javax.swing.JButton();
        StudentExit = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        DateLabel = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        panelCalendar = new javax.swing.JPanel();
        labelMonth = new javax.swing.JLabel();
        buttonNext = new javax.swing.JButton();
        buttonPrev = new javax.swing.JButton();
        labelYear = new javax.swing.JLabel();
        scrollTableCalendar = new javax.swing.JScrollPane();
        tableCalendar = new javax.swing.JTable();
        comboYear = new javax.swing.JComboBox();
        dateLabel = new javax.swing.JLabel();
        MainMenuBar = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        WelcomeLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        WelcomeLabel.setText("Welcome:");

        StudentNameField.setEditable(false);
        StudentNameField.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        StudentNameField.setBorder(null);
        StudentNameField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StudentNameFieldActionPerformed(evt);
            }
        });

        CourseYearLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        CourseYearLabel.setText("Course & Year Level:");

        StudentCourseYearField.setEditable(false);
        StudentCourseYearField.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        StudentCourseYearField.setBorder(null);
        StudentCourseYearField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StudentCourseYearFieldActionPerformed(evt);
            }
        });

        DroppedClassCardsLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        DroppedClassCardsLabel.setText("Class Cards");

        SubjectLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        SubjectLabel.setText("Subject");

        StudentSubjectField.setEditable(false);
        StudentSubjectField.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        StudentSubjectField.setText("Programming Applications");
        StudentSubjectField.setBorder(null);
        StudentSubjectField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StudentSubjectFieldActionPerformed(evt);
            }
        });

        StudentTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Date", "Number of Tardiness", "Number of Absences", "Remarks"
            }
        ));
        jScrollPane1.setViewportView(StudentTable);

        StudentChangePassword.setText("Change Password");
        StudentChangePassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StudentChangePasswordActionPerformed(evt);
            }
        });

        StudentExit.setText("Exit");
        StudentExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StudentExitActionPerformed(evt);
            }
        });

        DateLabel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        DateLabel.setText("Date:");

        panelCalendar.setBorder(javax.swing.BorderFactory.createTitledBorder("Calendar"));

        labelMonth.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelMonth.setText("January");

        buttonNext.setText(">>");

        buttonPrev.setText("<<");

        labelYear.setText("Change Year:");

        tableCalendar.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tableCalendar.setRowHeight(30);
        tableCalendar.getTableHeader().setReorderingAllowed(false);
        scrollTableCalendar.setViewportView(tableCalendar);
        tableCalendar.getColumnModel().getColumn(0).setResizable(false);
        tableCalendar.getColumnModel().getColumn(1).setResizable(false);
        tableCalendar.getColumnModel().getColumn(2).setResizable(false);
        tableCalendar.getColumnModel().getColumn(3).setResizable(false);
        tableCalendar.getColumnModel().getColumn(4).setResizable(false);
        tableCalendar.getColumnModel().getColumn(5).setResizable(false);
        tableCalendar.getColumnModel().getColumn(6).setResizable(false);
        refreshCalendar (realMonth, realYear);

        for (int i = realYear - 100; i <= realYear + 100; i++){
            comboYear.addItem(String.valueOf(i));
        }

        javax.swing.GroupLayout panelCalendarLayout = new javax.swing.GroupLayout(panelCalendar);
        panelCalendar.setLayout(panelCalendarLayout);
        panelCalendarLayout.setHorizontalGroup(
            panelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCalendarLayout.createSequentialGroup()
                .addComponent(buttonPrev)
                .addGap(147, 147, 147)
                .addComponent(labelMonth)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(buttonNext))
            .addGroup(panelCalendarLayout.createSequentialGroup()
                .addComponent(labelYear)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(comboYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(scrollTableCalendar)
        );
        panelCalendarLayout.setVerticalGroup(
            panelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCalendarLayout.createSequentialGroup()
                .addGroup(panelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonNext)
                    .addGroup(panelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(buttonPrev)
                        .addComponent(labelMonth)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrollTableCalendar, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelCalendarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelYear)
                    .addComponent(comboYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        buttonNext.addActionListener(new buttonNext_Action());
        buttonPrev.addActionListener(new buttonPrev_Action());
        refreshCalendar (realMonth, realYear);

        comboYear.addActionListener(new comboYear_Action());

        dateLabel.setText(date);

        jMenu1.setText("File");
        MainMenuBar.add(jMenu1);

        jMenu2.setText("Edit");
        MainMenuBar.add(jMenu2);

        setJMenuBar(MainMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(CourseYearLabel)
                            .addComponent(WelcomeLabel)
                            .addComponent(DroppedClassCardsLabel)
                            .addComponent(DateLabel)
                            .addComponent(SubjectLabel)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(StudentNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(StudentCourseYearField, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(StudentSubjectField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(dateLabel))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(59, 59, 59)
                        .addComponent(panelCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(StudentChangePassword)
                                .addGap(545, 545, 545)
                                .addComponent(StudentExit))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 737, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(WelcomeLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(StudentNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(CourseYearLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(StudentCourseYearField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(SubjectLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(StudentSubjectField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(11, 11, 11)
                                .addComponent(DateLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(dateLabel)
                                .addGap(52, 52, 52)
                                .addComponent(DroppedClassCardsLabel))
                            .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(panelCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(135, 135, 135)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(StudentExit)
                    .addComponent(StudentChangePassword, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void StudentNameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StudentNameFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_StudentNameFieldActionPerformed

    private void StudentCourseYearFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StudentCourseYearFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_StudentCourseYearFieldActionPerformed

    private void StudentSubjectFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StudentSubjectFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_StudentSubjectFieldActionPerformed

    private void StudentExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StudentExitActionPerformed
        // TODO add your handling code here:
        ExitDialog exit;
        exit = new ExitDialog();
        exit.setVisible(true);
        
    }//GEN-LAST:event_StudentExitActionPerformed

    private void StudentChangePasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StudentChangePasswordActionPerformed
        // TODO add your handling code here:
        ChangePassword changePass;
        changePass = new ChangePassword();
        changePass.setVisible(true);
    }//GEN-LAST:event_StudentChangePasswordActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(StudentWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(StudentWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(StudentWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(StudentWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new StudentWindow().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel CourseYearLabel;
    private javax.swing.JLabel DateLabel;
    private javax.swing.JLabel DroppedClassCardsLabel;
    private javax.swing.JMenuBar MainMenuBar;
    private javax.swing.JButton StudentChangePassword;
    private javax.swing.JTextField StudentCourseYearField;
    private javax.swing.JButton StudentExit;
    private javax.swing.JTextField StudentNameField;
    private javax.swing.JTextField StudentSubjectField;
    private javax.swing.JTable StudentTable;
    private javax.swing.JLabel SubjectLabel;
    private javax.swing.JLabel WelcomeLabel;
    static javax.swing.JButton buttonNext;
    static javax.swing.JButton buttonPrev;
    static javax.swing.JComboBox comboYear;
    private javax.swing.JLabel dateLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    static javax.swing.JLabel labelMonth;
    static javax.swing.JLabel labelYear;
    static javax.swing.JPanel panelCalendar;
    static javax.swing.JScrollPane scrollTableCalendar;
    static javax.swing.JTable tableCalendar;
    // End of variables declaration//GEN-END:variables

    public static void refreshCalendar(int month, int year){
        String[] months = {"January", "February", "March", "April", "May",
                "June", "July", "August", "September", "October", "November", "December"};
        int nod, som; //Number Of Days, Start Of Month

        buttonPrev.setEnabled(true); //Enable buttons at first
        buttonNext.setEnabled(true);
        if (month == 0 && year <= realYear-10){
            buttonPrev.setEnabled(false);
        } //Too early
        if (month == 11 && year >= realYear+100){
            buttonNext.setEnabled(false);
        } //Too late
        labelMonth.setText(months[month]); //Refresh the month label (at the top)
        labelMonth.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); //Re-align label with calendar
        comboYear.setSelectedItem(String.valueOf(year)); //Select the correct year in the combo box
        
        GregorianCalendar cal = new GregorianCalendar(year, month, 1);
        
        nod = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);
        som = cal.get(GregorianCalendar.DAY_OF_WEEK);
        
        //clearTable
        for (int i=0; i<6; i++){
            for (int j=0; j<7; j++){
                tableCalendar.getModel().setValueAt(null, i, j);
            }
        }
        
        //Draw calendar
        for (int i=1; i<=nod; i++){
            int row = new Integer((i+som-2)/7);
            int column  =  (i+som-2)%7;
            tableCalendar.getModel().setValueAt(i, row, column);
        }
        
        tableCalendar.setDefaultRenderer(tableCalendar.getColumnClass(0), new tableCalendarRenderer()); //Apply renderer
    }
    
    static class tableCalendarRenderer extends DefaultTableCellRenderer{
            public Component getTableCellRendererComponent (JTable table, Object value, 
            boolean selected, boolean focused, int row, int column){
              
            super.getTableCellRendererComponent(table, value, selected, focused, row, column);
            if (column == 0 || column == 6){ //Week-end
                setBackground(new Color(255, 220, 220));
            }
            else{ //Week
                setBackground(new Color(255, 255, 255));
            }
            if (value != null){
                if (Integer.parseInt(value.toString()) == realDay && currentMonth == realMonth && 
                        currentYear == realYear){ //Today
                    setBackground(new Color(220, 220, 255));
                }
            }
            setBorder(null);
            setForeground(Color.black);
            return this; 
        }

    }
    
    static class buttonPrev_Action implements ActionListener{
        public void actionPerformed (ActionEvent e){
            if (currentMonth == 0){ //Back one year
                currentMonth = 11;
                currentYear -= 1;
            }else{ //Back one month
                currentMonth -= 1;
            }
            refreshCalendar(currentMonth, currentYear);
        }
    }
    
    static class buttonNext_Action implements ActionListener{
        public void actionPerformed (ActionEvent e){
            if (currentMonth == 11){ //Foward one year
                currentMonth = 0;
                currentYear += 1;
            }else{ //Foward one month
                currentMonth += 1;
            }
            refreshCalendar(currentMonth, currentYear);
        }
    }
    
    static class comboYear_Action implements ActionListener{
        public void actionPerformed (ActionEvent e){
            if (comboYear.getSelectedItem() != null){
                String b = comboYear.getSelectedItem().toString();
                currentYear = Integer.parseInt(b); //Get the numeric value
                refreshCalendar(currentMonth, currentYear); //Refresh
            }
        }
    }
}
